﻿using System;
using Habanero.Base;
using Habanero.Faces.Base;
using Habanero.Faces.Base.ControlMappers;

namespace FireStarterModeller.UI.Dialogs
{
    public class OpenFileDialogExtendedTextBoxMapper : ControlMapper
    {
        private TextBoxMapper _textBoxMapper;

        public OpenFileDialogExtendedTextBoxMapper(IExtendedTextBox extendedTextBox, string propName, bool isReadOnly, IControlFactory factory) : base(extendedTextBox, propName, isReadOnly, factory)
        {
            _textBoxMapper = new TextBoxMapper(extendedTextBox.TextBox, propName, isReadOnly, factory);
        }

        public override void ApplyChangesToBusinessObject()
        {
            _textBoxMapper.ApplyChangesToBusinessObject();
        }

        public override void UpdateErrorProviderErrorMessage()
        {
            _textBoxMapper.UpdateErrorProviderErrorMessage();
        }

        public override string GetErrorMessage()
        {
            return _textBoxMapper.GetErrorMessage();
        }

        public override IBusinessObject BusinessObject
        {
            get { return _textBoxMapper.BusinessObject; }
            set
            {
                _textBoxMapper.BusinessObject = value;
                base.BusinessObject = _textBoxMapper.BusinessObject;
            }
        }

        protected override void InternalUpdateControlValueFromBo()
        {
            _textBoxMapper.Control.Text = Convert.ToString(GetPropertyValue());
        }

    }
}
